import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';

declare let $;

@Component({
  selector: 'app-subscribe',
  templateUrl: './subscribe.component.html',
  styleUrls: ['./subscribe.component.less']
})
export class SubscribeComponent implements OnInit {
  @Input()
  isVisible: any;
  @Input()
  url: string;
  @Output()
  event: EventEmitter<any> = new EventEmitter();

  constructor() {
  }

  ngOnInit() {
    // $('#qrcode').html(" ");
    console.log('几日');
    // console.log(this.url)
    // $('#qrcode').qrcode({width: 120, height: 120, text: this.url});
  }

  ngOnChanges() {
    if (this.url) {
      $('#qrcode').html('');
      let _this = this;
      setTimeout(function () {
        $('#qrcode').qrcode({width: 120, height: 120, text: _this.url});
      }, 600);
    }
  }

  handleCancel() {
    this.url = null;
    this.isVisible = false;
    this.event.emit(this.isVisible);
  }
}
